// index.js
// const app = getApp()
const { envList } = require('../../envList.js');

Page({
  data: {
    hotelList: [],
    hotelKeyWord: ""
  },
  onShow: function () {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
        this.getTabBar().setData({
            select: 3
        })
    }
  },
  async onReady() {
    const { result: { data } } = await wx.cloud.callFunction({
      name: 'quickstartFunctions', data: { type: 'getHotelList' }
    })
    this.setData({ hotelList: data })
    console.log(data, 111);
  },
  async onSearch(e) {
    const res = await wx.cloud.callFunction({
      name: 'quickstartFunctions', data: { type: 'getSearchList', searchKeyWord: this.data.hotelKeyWord, switchType: 'hotel'}
    })
    console.log(res.result.data, 111);
    this.setData({ hotelList: res.result.data })
  },
  onChange(e) {
    console.log(e);
    this.setData({
      hotelKeyWord: e.detail,
    });
  },
});
